package com.dut.bbs.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class ParseTop10 {
	/**
	 * 
	 * @param 十大热门页面的html源码
	 * @return 包含十大话题的帖子题目及地址的数组
	 */
	public static List<Map<String,String>> get10BigNews(String date)
	{
		List<Map<String,String>> listResult = new ArrayList<Map<String,String>>();

		Document doc = null;
		 doc = Jsoup.parse(date); 

		Elements eles = doc.getElementsByClass("list");
		for(Element e:eles.get(0).children())
		{
			if(e.text().equals("十大热门话题"))
			{
				continue;
			}
			Map<String,String> tMap= new HashMap<String, String>();
			tMap.put("url", e.child(0).attr("href"));
			if(listResult.size()==9)
				tMap.put("title", e.text().substring(3));
			else
				tMap.put("title", e.text().substring(2));
			listResult.add(tMap);
		}		
		return listResult;	
	}

}
